/**
 * @file am2302.h
 * @author PK (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2023-05-16
 *
 * @copyright Copyright (c) 2023
 *
 */
#ifndef _AM2302_H
#define _AM2302_H
#include "stdint.h"

typedef struct am2302
{
    float RH_Val;
    float Temp_Val;
    uint8_t RH_HByte;
    uint8_t RH_LByte;
    uint8_t Temp_HByte;
    uint8_t Temp_LByte;
    uint8_t Check_Byte;
} Am2302_TypeDef;
extern Am2302_TypeDef am2302_th;

// #define AM2302_PIN   (1ul << 27)
// #define DQ(x)      (x)?(LPC_GPIO1->FIOSET = AM2302_PIN):(LPC_GPIO1->FIOCLR = AM2302_PIN)
// #define DQ_Read       (LPC_GPIO1->FIOPIN & AM2302_PIN)

void DS_SET1(void);
void DS_SET0(void);
void DS_IN(void);
void DS_OUT(void);
uint8_t DS_GET(void);

uint8_t Am2302_Start(Am2302_TypeDef *p);
void Am2302_io_Output(void);
void Am2302_io_input(void);
void Am2302_delayus(unsigned int n);
uint8_t Am2302_ReadByte(void);
uint8_t Am2302_Data_Verify(Am2302_TypeDef *p);
void Am2302_GetValue(Am2302_TypeDef *p);

#endif
